|
Neurosis Engine
|
00001 00002 // Neurosis Engine - LP23.com 00003 // Copyright © Luigi Pino. All rights reserved. 00004 00005 /***************************************************************************/ 00006 00007 #ifndef _NEUROSIS_ENGINE_AUDIO_H_ 00008 #define _NEUROSIS_ENGINE_AUDIO_H_ 00009 00010 /***************************************************************************/ 00011 00012 #include "../neurosis/openal/vorbisfile.h" 00013 #include <vector> 00014 00015 /***************************************************************************/ 00016 00017 #pragma comment(lib, "code/neurosis/openal/ogg_static.lib") 00018 #pragma comment(lib, "code/neurosis/openal/openal32.lib") 00019 #pragma comment(lib, "code/neurosis/openal/vorbis_static.lib") 00020 #pragma comment(lib, "code/neurosis/openal/vorbisfile_static.lib") 00021 00022 /***************************************************************************/ 00023 00024 //------------------------------------------------ 00025 #define AUDIO_BUFFER 32768 // 32 KB buffer 00026 #define AL_PLAYING 0x1012 00027 #define AL_PAUSED 0x1013 00028 #define AL_STOPPED 0x1014 00029 //------------------------------------------------ 00030 00031 /***************************************************************************/ 00032 00034 class CNeurosisAudio { 00035 public: 00036 CNeurosisAudio(int totalChannels = 4); 00038 ~CNeurosisAudio(); 00039 00041 void Clear(int iChannel); 00043 int Get_State(int iChannel); 00045 bool Is_Initialized(); 00047 bool Load(int iChannel, char *filename, bool stream); 00049 void Loop(int iChannel, bool loopAudio); 00051 void Play(int iChannel); 00053 void Pause(int iChannel); 00055 void Stop(int iChannel); 00057 void Volume(int iChannel, float volumeAmount); 00059 void Update(); 00060 00061 private: 00062 class CAudioData { 00063 public: 00064 bool Stream(unsigned int buffer); 00065 void Update(); 00066 00067 OggVorbis_File pOggFile; // File pointer for streaming data 00068 std::vector<char> pBufferData; // Buffer for non-streaming data 00069 00070 bool mInUse; // Whether data file was loaded 00071 bool mLoop; // Whether to loop audio 00072 bool mStream; // Whether to stream audio 00073 int mFormat; // AL_FORMAT_MONO16, AL_FORMAT_STEREO16; 00074 int mSamplingRate; // Frequency 00075 // int mState; // AL_PLAYING, AL_PAUSED, AL_STOPPED 00076 unsigned int mBufferID[2]; // Buffer 00077 unsigned int mSourceID; // Audio index 00078 }; 00079 00080 CAudioData *pAudio; 00081 int mTotalChannels; // If mTotalChannels = 0, then OpenAl is not initialized 00082 }; 00083 00084 /***************************************************************************/ 00085 #endif
1.7.6.1